package com.cogwheel.framework.util.input;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import static com.cogwheel.framework.util.input.CKeyboardState.*;

public class CKeyboardListener implements KeyListener {
	
	public CKeyboardState keyState = NOTHING;
	public String keyBuffer = "";
	public char charBuffer;

	@Override
	public void keyTyped(KeyEvent e) {
		if (Character.isAlphabetic(e.getKeyChar()) || Character.isDigit(e.getKeyChar()) || e.getKeyChar() == ' '){
			keyState = BUTTON_TYPED;
			keyBuffer += e.getKeyChar();
			charBuffer = e.getKeyChar();
		}
	}

	@Override
	public void keyPressed(KeyEvent e) {
		keyState = BUTTON_PRESSED;
		charBuffer = e.getKeyChar();
	}

	@Override
	public void keyReleased(KeyEvent e) {
		keyState = BUTTON_RELEASED;
	}

}
